package com.swak.rabbit;

import com.swak.utils.StringUtils;

/**
 * 系统默认的消息队列
 * 
 * agruments 可见管理控制台:<br>
 * 
 * Message TTL | Auto expire | Max length | Max length bytes | Overflow
 * behaviour Dead letter exchange | Dead letter routing key | Single active
 * consumer | Maximum priority Lazy mode Master locator
 * 
 * @author lifeng
 */
public interface Constants {

	// dead config
	String x_dead_letter_exchange = "x-dead-letter-exchange";
	String x_dead_letter_routing_key = "x-dead-letter-routing-key";
	String x_message_ttl = "x-message-ttl";
	
	// Server queue
	String server_channel = "X.Server";
	
	// retry queue
	String retry1s_channel = "X.Retry1s";
	String retry5s_channel = "X.Retry5s";
	String retry10s_channel = "X.Retry10s";
	String retry30s_channel = "X.Retry30s";
	String retry60s_channel = "X.Retry60s";
	String retry120s_channel = "X.Retry120s";
	String retry180s_channel = "X.Retry180s";
	String retry240s_channel = "X.Retry240s";
	String retry300s_channel = "X.Retry300s";
	String retry360s_channel = "X.Retry360s";
	String retry420s_channel = "X.Retry420s";
	String retry480s_channel = "X.Retry480s";
	String retry540s_channel = "X.Retry540s";
	String retry600s_channel = "X.Retry600s";
	String retry1200s_channel = "X.Retry1200s";
	String retry1800s_channel = "X.Retry1800s";
	String retry3600s_channel = "X.Retry3600s";
	String retry7200s_channel = "X.Retry7200s";
	String dead_channel = "X.Dead";
	String retry_channel = "X.Retry";
	String fail_channel = "X.Fail";

	// retry - consumer queue
	String retry1s_channel_cus = "X.Retry1s_cus";
	String retry5s_channel_cus = "X.Retry5s_cus";
	String retry10s_channel_cus = "X.Retry10s_cus";
	String retry30s_channel_cus = "X.Retry30s_cus";
	String retry60s_channel_cus = "X.Retry60s_cus";
	String retry120s_channel_cus = "X.Retry120s_cus";
	String retry180s_channel_cus = "X.Retry180s_cus";
	String retry240s_channel_cus = "X.Retry240s_cus";
	String retry300s_channel_cus = "X.Retry300s_cus";
	String retry360s_channel_cus = "X.Retry360s_cus";
	String retry420s_channel_cus = "X.Retry420s_cus";
	String retry480s_channel_cus = "X.Retry480s_cus";
	String retry540s_channel_cus = "X.Retry540s_cus";
	String retry600s_channel_cus = "X.Retry600s_cus";
	String retry1200s_channel_cus = "X.Retry1200s_cus";
	String retry1800s_channel_cus = "X.Retry1800s_cus";
	String retry3600s_channel_cus = "X.Retry3600s_cus";
	String retry7200s_channel_cus = "X.Retry7200s_cus";

	// retry count
	String x_retry = "x-retry";

	// dead times
	int dead = 10000;

	// retry times
	int[] retrys = new int[] { 1 * 1000, 5 * 1000, 10 * 1000, 30 * 1000, 60 * 1000, 120 * 1000, 180 * 1000, 240 * 1000,
			300 * 1000, 360 * 1000, 420 * 1000, 480 * 1000, 540 * 1000, 600 * 1000, 1200 * 1000, 1800 * 1000,
			3600 * 1000, 7200 * 1000 };

	/**
	 * 是否重试的队列
	 * 
	 * @param queue
	 * @return
	 */
	static boolean isRetryMessage(String queue) {
		return StringUtils.isNotBlank(queue) && StringUtils.contains(queue, retry_channel);
	}
}
